<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>ws client</title>
</head>
<body>
    <p style="border:1px solid #000 ; width:600px; height:800px;" id="talkMsg" ></p>
    <input id="message" /> <button id="sendBtn" onclick="sendMsg()">发送</button>
</body>
<script>
<!--    值就是访问服务器中服务器类的一个地址-->
    let ws = new WebSocket("ws://localhost:8080/myWs1")
    ws.onopen = function() { /* 发送消息 */
        ws.send("hello...")
    }
    ws.onmessage = function (message) { /* 监听服务器端的消息发送 接收一个 message 参数 */
        document.getElementById("talkMsg").innerHTML = message.data ;
    }

    function sendMsg() {
        ws.send(document.getElementById("message").value );
        document.getElementById("message").value = "";
    }
</script>
</html>
